
from selenium.webdriver.common.by import By
from pages.base_page import BasePage

class HomePage(BasePage):
    """定义home页面"""

    url_ = "http://192.168.1.14/crm/index.php?m=dynamic&a=index"

    to_client_locator = (By.LINK_TEXT,"客户")
    sj_locator = (By.LINK_TEXT, '商机')
    contract_locator = (By.LINK_TEXT, '合同')
    more_locator = (By.LINK_TEXT, '更多')
    mark_locator = (By.LINK_TEXT, '营销')

    touxiang_locator = (By.CLASS_NAME,"avatar")
    zzjg_locator = (By.XPATH,"/html/body/div[1]/div/div/div[2]/ul[2]/li[6]/ul/li[4]/a")
    grzl_loctor = (By.LINK_TEXT,"个人资料")
    avatar_locator = (By.CSS_SELECTOR,"body > div.container > div.row > div.span3.knowledgecate > "
                                      "div > div.personal-panel > div:nth-child(2) > p:nth-child(1)")
    clue_locator = (By.LINK_TEXT,"线索")
    business_opportunity_locator = (By.LINK_TEXT,"商机")
    task_locator = (By.LINK_TEXT,"任务")
    finance_locator = (By.LINK_TEXT,"财务")

    def to_client(self):
        self.findE(self.to_client_locator).click()

    def get_current_url(self):
        return self.driver.current_url

    def enter_sj(self):
        self.find_element(self.sj_locator).click()

    def click_touxiang(self):
        self.find_element(self.touxiang_locator).click()

    def click_zzgj(self):
        self.find_element(self.zzjg_locator).click()

    def click_grzl(self):
        self.find_element(self.grzl_loctor).click()

    def avatar_text(self):
        avatar_element = self.find_element(self.avatar_locator)
        return avatar_element.text

    def click_clue(self):
        self.find_element(self.clue_locator).click()

    def click_customer(self):
        self.find_element(self.to_client_locator).click()

    def click_business(self):
        self.find_element(self.business_opportunity_locator).click()

    def click_task(self):
        self.find_element(self.task_locator).click()

    def click_finance(self):
        self.find_element(self.finance_locator).click()


    def enter_contract(self):
        self.find_element(self.contract_locator).click()

    def more(self):
        """点击更多"""
        self.find_element(self.more_locator).click()

    def point_mark(self):
        """点击营销"""
        self.find_element(self.mark_locator).click()

